{{include file="../tools/jquery_validator2.htm"}} 
{{include file="../tools/upload.htm"}} 

<script type="text/javascript">
     $(function () {
		
		Main.setCnTime()
		$(".dates").datepicker({changeMonth:true,changeYear:true});
		var file_names = ''
		var img_type = '*.gif; *.jpg; *.png'
		var img_limit = 1
		var img_size  = 0.5 
		Main.uploadInit('#avater','./ajax.php?act=uploader',true,img_limit,img_type,img_size)
		
		 
           
 });
</script>
{{if $session.user_info}}

<script>
$(function(){
   $('#user_register').validate({

				rules: {
					user_name: {
						minlength: 2,
						maxlength: 16,
						required: true,
						regexp:/^[^\W]+$/
						
		
					},
					passwd: {
						minlength: 2,
						required: true
		
					},
					passwd2: {
						minlength: 2,
						required: true,
						equalTo:"#passwd"
		
					}
					,
					name: {
						minlength: 2,
						required: true
						
		
					}
					,
					nick_name: {
						minlength: 2,
						required: true
		
					}
					,
					type_id: {
						
						required: true,
						digits:true
		
					}
				
					,
					tel: {
						minlength: 2,
						required: true,
						regexp:/^\d{11}$/
		
					}
					,
					email: {
						minlength: 2,
						required: true,
						email:true
		
					}
					,
					avater: {
						minlength: 2,
						required: true
		
					}
					
				},
		
				messages: {
					user_name: {
						regexp:'只允许输入16个字母和数字'
						
						
					},
					passwd2: {
						equalTo:"两次密码不匹配!"
					},
					email: {
						email:"Email格式错误!"
						
		
					},
					tel: {
						digits:"请输入正确的手机号码!"
		
					}
					
        	},
			success: function(element) {
				element
				.text('OK!').addClass('valid')
				.closest('.control-group').removeClass('error').addClass('success');
  			}
    	});	
})
</script>
{{else}}
<script>
$(function(){
   $('#user_register').validate({

				rules: {
					user_name: {
						minlength: 2,
						maxlength: 16,
						required: true,
						regexp:/^[^\W]+$/
						,ajaxCheck:{act:'is_register',field:'user_name',rev:true}
		
					},
					passwd: {
						minlength: 2,
						required: true
		
					},
					passwd2: {
						minlength: 2,
						required: true,
						equalTo:"#passwd"
		
					}
					,
					name: {
						minlength: 2,
						required: true
						
		
					}
					,
					nick_name: {
						minlength: 2,
						required: true
		
					}
					,
					type_id: {
						
						required: true,
						digits:true
		
					}
				
					,
					tel: {
						minlength: 2,
						required: true,
						regexp:/^\d{11}$/
		
					}
					,
					email: {
						minlength: 2,
						required: true,
						email:true,
						ajaxCheck:{act:'is_register',field:'email',rev:true}
		
					}
					,
					avater: {
						minlength: 2,
						required: true
		
					}
					
				},
		
				messages: {
					user_name: {
						regexp:'只允许输入16个字母和数字',
						ajaxCheck:'用户名已经存在!，请重新输入!'
						
					},
					passwd2: {
						equalTo:"两次密码不匹配!"
					},
					email: {
						email:"Email格式错误!",
						ajaxCheck:'Email已经存在!，请重新输入!'
		
					},
					tel: {
						digits:"请输入正确的手机号码!"
		
					}
					
        	},
			success: function(element) {
				element
				.text('OK!').addClass('valid')
				.closest('.control-group').removeClass('error').addClass('success');
  			}
    	});	
})
</script>
{{/if}}
<div class="userbox">
  <h2>用户注册</h2>
  <div class="left">
    <form name="register" id="user_register" method="post" >
      <table>
        <tr>
          <td><em>&#42;</em></td>
          <td width="80">用户名：</td>
          <td><input type="text" name="user_name" value="{{$user_info.user_name}}" {{if $session.user_info}} readonly="readonly"{{/if}}/></td>
        </tr>
        <tr>
          <td><em>&#42;</em></td>
          <td>密码：</td>
          <td><input type="password" name="passwd" id="passwd" /></td>
        </tr>
        <tr>
          <td><em>&#42;</em></td>
          <td>确认密码：</td>
          <td><input type="password"/ name="passwd2" id="passwd2"></td>
        </tr>
        <tr>
          <td><em>&#42;</em></td>
          <td>姓名：</td>
          <td><input type="text" name="name"  id="name" value="{{$user_info.info.name}}"/></td>
        </tr>
        <tr>
          <td><em>&#42;</em></td>
          <td>昵称：</td>
          <td><input type="text" name="nick_name" id="nick_name" value="{{$user_info.info.nick_name}}"/></td>
        </tr>
        <tr class="jigou">
          <td><em>&#42;</em></td>
          <td>所在机构：</td>
          <td><select name="type_id" id="type_id">
              <option value="">请选择</option>
              
         	{{foreach from=$typeids item=list key=key}}
            
              <option value="{{$list.type_id}}" {{if $user_info.type_id==$list.type_id}}selected="selected"{{/if}}>{{$list.name}}</option>
              
            {{/foreach}}
         
          
            </select></td>
        </tr>
        <tr>
          <td><em>&#42;</em></td>
          <td>头像：</td>
          <td><span  id="avater"> </span>
            <div class="up_files " id="avater_res"> 
            {{if $user_info.avater}}
             <div class="files file_0"><a><img height="60" name="{{$user_info.avater}}" src="{{$user_info.avater}}"></a> <img onclick="Main.delFile(0)" title="Delete" class="del_file" src="{{$s_path}}/images/uploadify-cancel.gif">  </div>
            {{/if}}
            </div>
            <input type="text" name="avater" id="avaters" class="size0" value="{{$user_info.avater}}"/></td>
        </tr>
        <tr>
          <td><em>&#42;</em></td>
          <td>手机号：</td>
          <td><input type="text" name="tel" value="{{$user_info.info.tel}}"/></td>
        </tr>
        <tr>
          <td><em>&#42;</em></td>
          <td>邮箱：</td>
          <td><input type="text" name="email" value="{{$user_info.email}}" {{if $session.user_info}} readonly="readonly"{{/if}}/></td>
        </tr>
        <tr>
          <td><em> </em></td>
          <td>性别：</td>
          <td><input type="radio" name="sex" value="1" {{if $user_info.sex=='1'}}checked="checked"{{/if}}/>
            男
            <input type="radio" name="sex" value="2" {{if $user_info.sex=='2'}}checked="checked"{{/if}}/>
            女</td>
        </tr>
        <tr class="shri">
          <td><em> </em></td>
          <td>生日：</td>
          <td><input type="text" name="birthday" class="dates" readonly="readonly" value="{{$user_info.birthday}}"/></td>
        </tr>
        <tr>
          <td><em> </em></td>
          <td></td>
          <td><input  type="hidden" value="register" name="user_act"/>
            <input  type="hidden" value="{{$user_info.user_id}}" name="user_id"/>
            <input  class="zhuce"  type="submit" value="" id="button"/></td>
        </tr>
        <tr>
          <td><em> </em></td>
          <td></td>
          <td><em>&#42;</em> 为必填选项</td>
        </tr>
      </table>
    </form>
  </div>
  <!--left end--> 
  
  {{include file="./user_act_right.htm"}} 
  <!--right end--> 
  
</div>
